//
//  RankingListViewController.m
//  安好
//
//  Created by qinlongqing on 14-9-9.
//  Copyright (c) 2014年 冯凯. All rights reserved.
//

#import "RankingListViewController.h"
#import "RankingListDetailViewController.h"

@interface RankingListViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    NSArray *testListArray;
}
@end

@implementation RankingListViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"排行榜";
    self.view.backgroundColor = UIColorFromRGB(0xecf4f6);
    
    [self makeNavBar];
    
//    testListArray = [NSArray arrayWithObjects:@"视力",@"心率", nil];
    testListArray = [NSArray arrayWithObjects:@"视力", nil];

    UITableView *tableView = [[UITableView alloc]init];
    tableView.frame = CGRectMake(0, 14, kScreenWidth, kScreenHeight - 64 - 14);
//    if (IPHONE5_OR_LATER) {
//        tableView.frame = CGRectMake(0, 14, 320, 488);
//    }
//    else{
//        tableView.frame = CGRectMake(0, 14, 320, 400);
//    }
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:tableView];
}

- (void)makeNavBar{
    UIBarButtonItem *backBtnImg = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"公用_返回.png"] style:UIBarButtonItemStylePlain target:self action:@selector(doBack)];
    [backBtnImg setTintColor:[UIColor whiteColor]];
    self.navigationItem.leftBarButtonItem = backBtnImg;
}

-(void)doBack{
    [self.navigationController popViewControllerAnimated:YES];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return testListArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 40;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        UIImageView *cellLine = [[UIImageView alloc]initWithFrame:CGRectMake(0, 39, 320, 1)];
        cellLine.backgroundColor = UIColorFromRGB(0xecf4f6);
        [cell.contentView addSubview:cellLine];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text = [testListArray objectAtIndex:indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    RankingListDetailViewController *rankingListDetailViewController = [[RankingListDetailViewController alloc]init];
    rankingListDetailViewController.currentRow = indexPath.row;
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    [self.navigationController pushViewController:rankingListDetailViewController animated:YES];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
